package pdfsetter.core.schema.onefile;

import pdfsetter.core.schema.DocumentSchema;
import pdfsetter.core.schema.SimpleDocumentSchema;
import pdfsetter.core.schema.SinglePageSchema;
import pdfsetter.core.schema.advanced.FilePageSelector;

/**
 * This is simple representation of {@link OneFileDocumentSchemaPattern} in which we only represent documents with same layout on every page. We only need
 * selector and single page schema. Having simple documents by compounding them we can produce any document schema for one file.
 * 
 * @author Andrzej Dorobisz
 */
public class SimpleOneFileDocumentSchemaPattern implements OneFileDocumentSchemaPattern {
    private final SinglePageSchema pageSchema;
    private final FilePageSelector selector;

    public SimpleOneFileDocumentSchemaPattern(SinglePageSchema singlePageSchema, FilePageSelector selector) {
        this.pageSchema = singlePageSchema;
        this.selector = selector;
    }

    @Override
    public DocumentSchema produceDocumentSchema(int fileNumber, int fileSize) {
        return new SimpleDocumentSchema(pageSchema, new FixedFileFillingSchema(fileNumber, selector.selectPages(fileSize)));
    }
}
